<template>
  <div class="declare">
    <div class="left">
        <el-button type="primary" @click="addCompany">新增</el-button>
        <div class="tree_div">
            <el-input v-model="filterText" placeholder="请输入" />
            <div class="tree">
                <el-scrollbar style="width: 100%; height: 100%">
                    <el-tree
                    style="max-width: 200px;height:75vh"
                    :data="tenantList"
                    :props="props"
                    :load="loadNode"
                    @node-click="handleNodeClick"
                    node-key="id"
                    ref="treeRef" 
                    :filter-node-method="filterNode"
                    lazy
                    :expand-on-click-node="false"
                    highlight-current
                    >
                        <template #default="{ data }">
                            <div
                            v-html="data.name.replace(new RegExp(filterText, 'g'), `<span style='color:orange'>${filterText}</span>`)">
                            </div>
                        </template>
                    </el-tree>
                </el-scrollbar>
            </div>
        </div>
    </div>
    <div class="right">
      <el-scrollbar height="height:100%">
        <!-- 企业头部信息卡片 -->
        <p>基础信息</p>
      <div class="other-info" >
        <el-descriptions class="mb-2 mt-2" :column="2" size="default" border>
            <el-descriptions-item
                label="单位名称"
                label-align="center"
                align="center"
                width="100px"
                >
            <div class="company-decs">
              <el-input v-model="company.name" @blur="()=>{companyNameVisable = false}" v-if="companyNameVisable" />
              <p class="cell-item-dec" v-else>{{company.name}}</p>
              <el-icon color="#409EFF"@click="openCompanyName" v-if="!companyNameVisable"><EditPen /></el-icon>
            </div>
            </el-descriptions-item>
            <el-descriptions-item
                label="主营产品"
                label-align="center"
                align="center"
                width="100px"
                >
                <div class="company-decs">
                  <el-input v-model="company.product" @blur="()=>{companyProductVisable = false}" v-if="companyProductVisable" />
                  <p class="cell-item-dec" v-else>{{company.product}}</p>
                  <el-icon color="#409EFF"@click="openCompanyProduct" v-if="!companyProductVisable"><EditPen /></el-icon>
                </div>
            </el-descriptions-item>
            <el-descriptions-item
                label="年度收入"
                label-align="center"
                align="center"
                width="100px"
                >
                <div class="company-decs">
                  <el-input v-model="company.amount" @blur="()=>{companyAmountVisable = false}" v-if="companyAmountVisable" />
                  <p class="cell-item-dec" v-else>{{company.amount}}</p>
                  <el-icon color="#409EFF"@click="openCompanyAmount" v-if="!companyAmountVisable"><EditPen /></el-icon>
                </div>
            </el-descriptions-item>
            <el-descriptions-item
                label="联系方式"
                label-align="center"
                align="center"
                width="100px"
                >
                <div class="company-decs">
                  <el-input v-model="company.contact" @blur="()=>{companyContactVisable = false}" v-if="companyContactVisable" />
                  <p class="cell-item-dec" v-else>{{company.contact}}</p>
                  <el-icon color="#409EFF"@click="openCompanyContact" v-if="!companyContactVisable"><EditPen /></el-icon>
                </div>
            </el-descriptions-item>
            <el-descriptions-item
                label="客户类型"
                label-align="center"
                align="center"
                width="100px"
                >
                <div class="company-decs">
                  <el-input v-model="company.type" @blur="()=>{companyTypeVisable = false}" v-if="companyTypeVisable" />
                  <p class="cell-item-dec" v-else>{{company.type}}</p>
                  <el-icon color="#409EFF"@click="openCompanyType" v-if="!companyTypeVisable"><EditPen /></el-icon>
                </div>
            </el-descriptions-item>
            <el-descriptions-item
                label="单位简介"
                label-align="center"
                align="center"
                width="100px"
                >
                <div class="company-decs">
                  <el-input v-model="company.decs" @blur="()=>{companyDecsVisable = false}" v-if="companyDecsVisable" />
                  <p class="cell-item-dec" v-else>{{company.decs}}</p>
                  <el-icon color="#409EFF"@click="openCompanyDecs" v-if="!companyDecsVisable"><EditPen /></el-icon>
                </div>
            </el-descriptions-item>
            <el-descriptions-item
                label="办公地址"
                label-align="center"
                align="center"
                width="100px"
                >
                <div class="company-decs">
                  <el-input v-model="company.address" @blur="()=>{companyAddressVisable = false}" v-if="companyAddressVisable" />
                  <p class="cell-item-dec" v-else>{{company.address}}</p>
                  <el-icon color="#409EFF"@click="openCompanyAddress" v-if="!companyAddressVisable"><EditPen /></el-icon>
                </div>
            </el-descriptions-item>
        </el-descriptions>
      </div>
      <div class="tabs">
        <el-tabs class="demo-tabs" v-model="activeName" @tab-click="changeTab">
          <el-tab-pane label="资讯日报" name="first">
            <el-form :model="infoForm" class="filter-box">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="单位名称">
              <el-input @keyup.enter="infoQuery" clearable v-model="infoForm.companyName" placeholder="请输入单位名称">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目名称">
              <el-input
                v-model="infoForm.itemName"
                @keyup.enter="infoQuery"
                placeholder="请输入项目名称"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="立项金额">
              <div class="flex items-center justify-between">
                <el-input
                  v-model="infoForm.moneyStart"
                  placeholder="立项金额(万元)"
                  @input="(e:any) => validateInput(e,1)"
                  clearable
                />
                &nbsp;
                <span class="cut-line">-</span>
                &nbsp;
                <el-input
                  v-model="infoForm.moneyEnd"
                  placeholder="立项金额(万元)"
                  @input="(e:any) => validateInput(e,2)"
                />
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目批次">
              <!-- <el-date-picker
                v-model="form.batchs"
                format="YYYY"
                value-format="YYYY"
                type="year"
                placeholder="选择批次"
              /> -->
              <el-select
                  class="w-full"
                  v-model="infoForm.batchs"
                  multiple
                  collapse-tags
                  collapse-tags-tooltip
                  placeholder="选择批次"
                  @change="infoQuery"
                  clearable
                >
                  <el-option
                    v-for="item in batchs"
                    :key="item.dictValue"
                    :label="item.dictLabel"
                    :value="item.dictValue"
                  />
                </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目类型">
              <el-select
                v-model="infoForm.itemTypes"
                multiple
                collapse-tags
                collapse-tags-tooltip
                placeholder="请选择项目类型"
                @change="infoQuery"
                clearable
              >
                <el-option
                  v-for="item in projectTypes"
                  :key="item.dictValue"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>

          </el-col>
          <el-col :span="6">
            <el-button type="primary" plain @click="infoQuery">查询</el-button>
            <!--  -->
            <el-button type="info" :class="clear?'clear':'noClear'" @click="resetForm">重置</el-button>
          </el-col>
        </el-row>
      </el-form>
            <el-table :data="infoList"  class="el-table"
          stripe
          v-loading="projectApprovalLoading"
          element-loading-text="正在拼命加载中..."
          :row-class-name="tableRowClassName"
          :header-cell-style="{ background: '#2186F0', color: '#fff', textAlign: 'center' }"
          style="width: 100%"
          >
            <el-table-column type="index" label="序号" width="80" align="center" show-overflow-tooltip/>
            <el-table-column prop="title" label="资讯名称" width="180" align="center" show-overflow-tooltip>

            </el-table-column>
            <el-table-column prop="proof" label="文号" width="180" align="center" show-overflow-tooltip/>
            <el-table-column prop="year" label="批次" width="180" align="center" show-overflow-tooltip/>
            <el-table-column prop="character" label="性质" width="180" align="center" show-overflow-tooltip/>
            <el-table-column prop="completeTimeStr" label="成文日期" width="180" align="center" show-overflow-tooltip/>
            <el-table-column fixed="right" label="操作" align="center">
              <template #default>
                <el-button link type="primary" size="small" @click="handleCaseClick">
                  新增案例
                </el-button>
              </template>
            </el-table-column>
            </el-table>
            <el-pagination
              style="margin-top: 10px;"
              v-model:current-page="infoCurrentPage"
              v-model:page-size="infoPageSize"
              :page-sizes="[100, 200, 300, 400]"
              layout="total, sizes, prev, pager, next, jumper"
              :total="infoTotal"
              @size-change="handleSizeChangeInfo"
              @current-change="handleCurrentChangeInfo"
            />
          </el-tab-pane>
          <el-tab-pane label="立项查询" name="scond">
            <el-form :model="form" class="filter-box">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="单位名称">
              <el-input @keyup.enter="projectApprovalQuery" clearable v-model="projectApprovalForm.companyName" placeholder="请输入单位名称">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目名称">
              <el-input
                v-model="projectApprovalForm.itemName"
                @keyup.enter="projectApprovalQuery"
                placeholder="请输入项目名称"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="立项金额">
              <div class="flex items-center justify-between">
                <el-input
                  v-model="projectApprovalForm.moneyStart"
                  placeholder="立项金额(万元)"
                  @input="(e:any) => validateInput(e,1)"
                  clearable
                />
                &nbsp;
                <span class="cut-line">-</span>
                &nbsp;
                <el-input
                  v-model="projectApprovalForm.moneyEnd"
                  placeholder="立项金额(万元)"
                  @input="(e:any) => validateInput(e,2)"
                />
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目批次">
              <!-- <el-date-picker
                v-model="form.batchs"
                format="YYYY"
                value-format="YYYY"
                type="year"
                placeholder="选择批次"
              /> -->
              <el-select
                  class="w-full"
                  v-model="projectApprovalForm.batchs"
                  multiple
                  collapse-tags
                  collapse-tags-tooltip
                  placeholder="选择批次"
                  @change="projectApprovalQuery"
                  clearable
                >
                  <el-option
                    v-for="item in batchs"
                    :key="item.dictValue"
                    :label="item.dictLabel"
                    :value="item.dictValue"
                  />
                </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="项目类型">
              <el-select
                v-model="projectApprovalForm.itemTypes"
                multiple
                collapse-tags
                collapse-tags-tooltip
                placeholder="请选择项目类型"
                @change="projectApprovalQuery"
                clearable
              >
                <el-option
                  v-for="item in projectTypes"
                  :key="item.dictValue"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>

          </el-col>
          <el-col :span="6">
            <el-button type="primary" plain @click="projectApprovalQuery">查询</el-button>
            <!--  -->
            <el-button type="info" :class="clear?'clear':'noClear'" @click="resetForm">重置</el-button>
          </el-col>
        </el-row>
      </el-form>
            <el-table
          class="el-table"
          stripe
          v-loading="projectApprovalLoading"
          element-loading-text="正在拼命加载中..."
          :row-class-name="tableRowClassName"
          :data="projectApprovalList"
          :header-cell-style="{ background: '#2186F0', color: '#fff', textAlign: 'center' }"
          style="width: 100%"
        >
            <el-table-column type="index" label="序号" width="80" align="center" show-overflow-tooltip/>
            <el-table-column prop="incorporation" label="单位名称" width="180" align="center" show-overflow-tooltip>
              <template #default="scoped">
                
                <el-link type="primary" >
                  {{hightLight(projectApprovalForm.itemName,scoped.row.incorporation)}}
                  <!-- <span v-html="hightLight(projectApprovalForm.itemName,scoped.row.incorporation)"></span> -->
                </el-link>
              </template>
            </el-table-column>
            <el-table-column prop="project" label="项目名称" width="180" align="center" show-overflow-tooltip>
              <template #default="scoped">
                <span v-html="hightLight(project,scoped.row.project)"></span>
              </template>
            </el-table-column>
            <el-table-column prop="amount" label="立项金额" width="180" align="center" show-overflow-tooltip/>
            <el-table-column prop="year" label="项目批次" width="180" align="center" show-overflow-tooltip/>
            <el-table-column prop="status" label="项目状态" width="180" align="center" show-overflow-tooltip/>
            <el-table-column prop="itemClass" label="项目类别" width="180" align="center" show-overflow-tooltip/>
            <el-table-column fixed="right" label="操作" align="center">
                  <template #default>
                    <el-button link type="primary" size="small" @click="handleCaseClick">
                      新增案例
                    </el-button>
                  </template>
                </el-table-column>
        </el-table>
        <el-pagination
        style="margin-top: 10px;"
      v-model:current-page="projectApprovalCurrentPage"
      v-model:page-size="projectApprovalPageSize"
      :page-sizes="[100, 200, 300, 400]"
      layout="total, sizes, prev, pager, next, jumper"
      :total="projectApprovalTotal"
      @size-change="handleSizeChangeProjectApproval"
      @current-change="handleCurrentChangeProjectApproval"
    />
          </el-tab-pane>
          <el-tab-pane label="申报规划" name="third">
            
          </el-tab-pane>
          <el-tab-pane label="统计分析" name="fourth">
            
        </el-tab-pane>
        </el-tabs>
      </div>
    </el-scrollbar>
    </div>
    <el-dialog
    v-model="dialogAddVisible"
    title="新增信息"
    width="900"
    :before-close="handleClose"
  >
    <el-form :model="form" label-width="auto" style="max-width: 600px">
        <el-form-item label="单位名称">
            <el-input v-model="form.name" />
        </el-form-item>
        <el-form-item label="客户名称">
            <el-input v-model="form.name" />
        </el-form-item>
        <el-form-item label="主营业务">
            <!-- <el-input v-model="form.name" /> -->
            <el-autocomplete
            style="width: 100%;"
                v-model="form.business"
                :fetch-suggestions="querySearchAsync"
                placeholder=""
                @select="handleSelect"
            >
      </el-autocomplete>
        </el-form-item>
        <el-form-item label="年度收入">
            <div class="income_label">
                <div style="width: 160px;">年度</div>
                <div style="width: 160px;">营收</div>
            </div>
            <div class="income_input" v-for="(item,index) in incomeList">
                <div style="width: 150px;margin-right: 10px;"><el-input v-model="item.year" /></div>
                <div style="width: 150px;margin-right: 10px;"><el-input v-model="item.amount" /></div>
                
                <el-button type="primary" circle @click="addIncome">
                  <el-icon :size="15" color="#FFFFFF">
                    <Plus />
                  </el-icon>
                </el-button>
                <el-button type="danger" circle  @click="deleteIncome(item,index)">
                  <el-icon :size="15" color="#FFFFFF">
                    <Delete />
                  </el-icon>
                </el-button>
            </div>
        </el-form-item>
        <el-form-item label="办公地址">
            <el-input v-model="form.name" />
        </el-form-item>
        <el-form-item label="联系方式">
          <div style="display: flex;justify-content: space-between;flex-direction: column;">
            <div class="income_label">
                <div style="width: 110px;">姓名</div>
                <div style="width: 110px;">职务</div>
                <div style="width: 110px;">电话</div>
                <div style="width: 110px;">邮箱</div>

            </div>
            <div class="income_input" v-for="(item,index) in incomeList">
              <div style="width: 100px;margin-right: 10px;"><el-input v-model="item.year" /></div>
              <div style="width: 100px;margin-right: 10px;"><el-input v-model="item.year" /></div>
              <div style="width: 100px;margin-right: 10px;"><el-input v-model="item.year" /></div>
              <div style="width: 100px;margin-right: 10px;"><el-input v-model="item.amount" /></div>
              <el-button type="primary" circle @click="addIncome">
                  <el-icon :size="15" color="#FFFFFF">
                    <Plus />
                  </el-icon>
                </el-button>
                <el-button type="danger" circle  @click="deleteIncome(item,index)">
                  <el-icon :size="15" color="#FFFFFF">
                    <Delete />
                  </el-icon>
                </el-button>
              <!-- <el-button type="primary" :icon="Edit" circle @click="addIncome"/>
              <el-button type="danger" :icon="Delete" circle  @click="deleteIncome(item,index)"/> -->
          </div>
          </div>
        </el-form-item>
        <el-form-item label="客户类型">
          <el-select v-model="form.value" placeholder="请选择">
            <el-option
              v-for="item in customerType"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="单位简介">
            <!-- <el-input v-model="form.name"  type="textarea"/> -->
             <wangEditor/>
        </el-form-item>
    </el-form>

    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogAddVisible = false">Cancel</el-button>
        <el-button type="primary" @click="dialogAddVisible = false">
          Confirm
        </el-button>
      </div>
    </template>
  </el-dialog>

  <el-dialog
    v-model="dialogAddCaseVisible"
    title="新增案例"
    width="900"
    :before-close="handleClose"
  >
    <div>
          <el-button type="primary" @click="addService">新增</el-button>
          <el-table :data="tableData"  class="el-table"
          stripe
          v-loading="projectApprovalLoading"
          element-loading-text="正在拼命加载中..."
          :row-class-name="tableRowClassName"
          :header-cell-style="{ background: '#2186F0', color: '#fff', textAlign: 'center' }"
          style="width: 100%;margin-top: 10px;">
              <el-table-column type="selection" width="55" />
              <el-table-column prop="date" label="公司名称" width="180">
                  <template #default="scope">
                      <el-input v-model="scope.row.date"/>
                  </template>
              </el-table-column>
              <el-table-column prop="name" label="Name" width="180">
                  <template #default="scope">
                      <el-input v-model="scope.row.name"/>
                  </template>
              </el-table-column>
              <el-table-column prop="address" label="Address">
                  <template #default="scope">
                      <el-input v-model="scope.row.address"/>
                  </template>
              </el-table-column>
              <el-table-column label="操作" fixed="right" align="center">
          <template #default="scope">
                      <el-button link type="primary" @click="deleteService(scope.$index)">
                          删除
            </el-button>
                  </template>
              </el-table-column>
          </el-table>   
    </div>
    <template #footer>
    <div class="dialog-footer">
      <el-button @click="dialogAddCaseVisible = false">Cancel</el-button>
      <el-button type="primary" @click="dialogAddCaseVisible = false">
        Confirm
      </el-button>
    </div>
    </template>
</el-dialog>
  </div>
</template>

<script setup lang="ts">
import { getNewsCollect,queryArticle } from "@/service/article"
import { hightLight  } from '@/utils/index'
import wangEditor from './components/wangEditor.vue'
import { ref,onMounted,computed } from "vue";
const filterText = ref('')
const dialogAddVisible = ref(false)
const dialogAddCaseVisible = ref(false)
const tenantList = ref([]) // 宗教场所
const company = ref({
  name:'xxx公司',
  product:'xxx产品',
  amount:'ww',
  contact:'xxxx',
  type:'xxxxx',
  decs:'xxxxx',
  address:'xxxxx'
})
const customerType = ref([
  {label:'潜在',value:1},{label:'现有',value:0}
])
const infoForm = ref({})
const projectApprovalForm = ref({})
const batchs = computed(()=>{
    const year = []
    const date = new Date();
      const currentYear = date.getFullYear();
      // year.push({ dictLabel: currentYear, dictValue: currentYear })
      for(var i=0;i<20;i++){
        year.push({ dictLabel: currentYear-i, dictValue: currentYear-i })
      }
    return year
  })
  const projectTypes = [
    { dictLabel: "专项资金", dictValue: "1" },
    { dictLabel: "荣誉资质", dictValue: "2" },
    { dictLabel: "赛事活动", dictValue: "3" },
    { dictLabel: "其他", dictValue: "4" }
  ]
const form = ref({name:'',business:'',income:[{year:'',amount:0}]})
const props = {
  label: 'name',
  children: 'children',
  isLeaf: 'isLeaf'
}

interface LinkItem {
  value: string
  link: string
}
const links = ref<LinkItem[]>([])
const loadAll = () => {
  return [
    { value: 'vue', link: 'https://github.com/vuejs/vue' },
    { value: 'element', link: 'https://github.com/ElemeFE/element' },
    { value: 'cooking', link: 'https://github.com/ElemeFE/cooking' },
    { value: 'mint-ui', link: 'https://github.com/ElemeFE/mint-ui' },
    { value: 'vuex', link: 'https://github.com/vuejs/vuex' },
    { value: 'vue-router', link: 'https://github.com/vuejs/vue-router' },
    { value: 'babel', link: 'https://github.com/babel/babel' },
  ]
}

const activeName = ref('first')
const projectApprovalLoading = ref(false)

let timeout: ReturnType<typeof setTimeout>
const querySearchAsync = (queryString: string, cb: (arg: any) => void) => {
  const results = queryString
    ? links.value.filter(createFilter(queryString))
    : links.value

  clearTimeout(timeout)
  timeout = setTimeout(() => {
    cb(results)
  }, 5000 * Math.random())
}
const createFilter = (queryString: string) => {
  return (restaurant: LinkItem) => {
    return (
      restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
    )
  }
}
const handleSelect = (item: Record<string, any>) => {
  console.log(item)
}

const incomeList = ref([{year:'',amount:0}])
// const income = ref({year:'',:amount0})
const addIncome = () => {
    incomeList.value.push({year:'',amount:0})
}
const deleteIncome = (value,index) => {
    incomeList.value.splice(index,1)
}

const tableData = ref([
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
])
const tableRowClassName = ({
  row,
  rowIndex
}: {
  row: any;
  rowIndex: number;
}) => {
  if (row.type === 2) {
    return "info-row";
  } else {
    return "";
  }
};
const addService = () =>{
    console.log(tableData.value)
    tableData.value.push({date:'',name:'',address:''})
}
const deleteService = (index:number)=> {
    tableData.value.splice(index,1)
}
// 信息填写
const companyNameVisable = ref(false)
const openCompanyName = () =>{
  companyNameVisable.value = true
}
const companyProductVisable = ref(false)
const openCompanyProduct = () =>{
  companyProductVisable.value = true
}
const companyAmountVisable = ref(false)
const openCompanyAmount = () =>{
  companyAmountVisable.value = true
}
const companyContactVisable = ref(false)
const openCompanyContact = () =>{
  companyContactVisable.value = true
}
const companyTypeVisable = ref(false)
const openCompanyType = () =>{
  companyTypeVisable.value = true
}
const companyDecsVisable = ref(false)
const openCompanyDecs = () =>{
  companyDecsVisable.value = true
}
const companyAddressVisable = ref(false)
const openCompanyAddress = () =>{
  companyAddressVisable.value = true
}
// over

// 定义过滤规则
const filterNode = (value, data) => {
  if (!value) return true
  return data.name.indexOf(value) !== -1
}
/** 查询场所列表 */
const getTenantList = async () => {
//   tenantList.value = await TenantApi.getTenantList()
tenantList.value = [{name:'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx客户',children:[{name:'xxx经理'}],isLeaf: 'isLeaf'}]
}
const loadNode = async (node, resolve) => {
  //如果展开第一级节点，从后台加载一级节点列表
  if (node.level == 0) {
    loadfirstnode(resolve)
  }
  //如果展开其他级节点，动态从后台加载下一级节点列表
  if (node.level >= 1) {
    loadchildnode(node, resolve)
  }
}
//加载第一级节点
const loadfirstnode = async (resolve) => {
  getTenantList()
  return resolve(tenantList.value)
}
//加载节点的子节点集合
const loadchildnode = async (node, resolve) => {
  // console.log("超过二级的", node, node.level);
//   await getList(node.data.id)
  return resolve([{name:'xxx公司1'}])
}
/** 查询设备列表 */
const getList = async (e) => {
//   deviceList.value = await EquipmentApi.listByPlaceId(e)
//   deviceList.value = deviceList.value.map((val) => {
//     return { ...val, name: val.deviceName, type: 'device' }
//   })
}
const handleNodeClick = async (node) => {
     //获取详细信息
}
const addCompany = async () =>{
    dialogAddVisible.value = true

}
const handleCaseClick = () =>{
  dialogAddCaseVisible.value = true
}
const handleClose = async () =>{
    dialogAddVisible.value = false
    dialogAddCaseVisible.value = false
}
const changeTab = (val) =>{
if(val.index==0){
  infoQuery()
}else if(val.index==1){
  projectApprovalQuery()
}
}
const infoList = ref([])
const infoTotal = ref(0)
const infoQuery = () =>{
    getNewsCollect({pageNum:infoCurrentPage.value,pageSize:infoPageSize.value},{...infoForm.value,policyId:"17179",searchType:"4"}).then(res=>{
      console.log(res.rows)
      infoTotal.value = res.total
      infoList.value = res.rows
    })
}
const projectApprovalList = ref([])
const projectApprovalTotal = ref(0)
const projectApprovalQuery = () =>{
    queryArticle({policyId:"17179",searchType:"4",...projectApprovalForm.value},{pageNum:projectApprovalCurrentPage.value,pageSize:projectApprovalPageSize.value}).then(res=>{
      console.log(res.rows)
      projectApprovalTotal.value = res.total
      projectApprovalList.value = res.rows
    })
}

const infoCurrentPage = ref(1)
const infoPageSize = ref(100)
const handleSizeChangeInfo = (val) =>{
  infoPageSize.value = val
}
const handleCurrentChangeInfo = (val) =>{
  infoCurrentPage.value = val
}
const projectApprovalCurrentPage = ref(1)
const projectApprovalPageSize = ref(100)
const handleSizeChangeProjectApproval = (val) =>{
  projectApprovalPageSize.value = val
}
const handleCurrentChangeProjectApproval = (val) =>{
  projectApprovalCurrentPage.value = val
}
onMounted(() => {
  links.value = loadAll()
})

</script>

<style scoped lang="postcss">
.declare{
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    margin: 10px;
    .left{
        border-radius: 5px;
        width: 20vw;
        height: 90vh;
        background-color: #fff;
        margin-right: 10px;
        padding: 10px;
        .tree_div{
            width: 100%;
            margin-top: 10px;

        }
    }
    .right{
        border-radius: 5px;
        width: 40vw;
        height: 90vh;
        background-color: #fff;
        padding: 10px;
        .other-info{
          .company-decs{
            display:flex;
            justify-content: center;
            align-items:center;
            .cell-item-dec{
              margin-right: 10px;
            }
          }
        }
        .tabs{
            :deep(.el-tabs__nav-scroll) {
                font-family: Microsoft YaHei;
                font-weight: 400;
                font-size: 16px;
              }
              :deep(.el-tabs__active-bar) {
                background-color: #3662ae;
              }
              :deep(.el-tabs__item) {
                color: #3662ae;
                padding: 0 20px !important;
              }
              :deep(.el-tabs__item.is-active) {
                color: #ffffff;
                background-color: #3662ae;
              }
              :deep(.el-tabs__nav-wrap::after) {
                height: 4px;
                background-color: #3662ae;
              }
              :deep(.el-table) {
                border-radius: 10px;
                tr{
                  background-color:#ecf5ff;
                }
                /* --el-table__row--striped{
                  background-color:#ecf5ff;
                } */
                .info-row {
                  /* --el-table-tr-bg-color: #ecf5ff; */
                  /* td.el-table__cell,th.el-table__cell.is-leaf {
                    border-bottom: 1px solid #449EFF !important;
                  } */
                }
            
              }
            
        }
    }
    .income_label{
        display: flex;
    }
    .income_input{
        display: flex;
        justify-content: space-around;
    }
}
</style>